package com.kgc.ssm.mapper;

import com.kgc.ssm.entity.SysUsers;
import com.kgc.ssm.entity.SysUsersExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;

public interface SysUsersMapper {
    long countByExample(SysUsersExample example);

    int deleteByExample(SysUsersExample example);

    int deleteByPrimaryKey(Long id);

    int insert(SysUsers row);

    int insertSelective(SysUsers row);

    List<SysUsers> selectByExampleWithRowbounds(SysUsersExample example, RowBounds rowBounds);

    List<SysUsers> selectByExample(SysUsersExample example);

    SysUsers selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("row") SysUsers row, @Param("example") SysUsersExample example);

    int updateByExample(@Param("row") SysUsers row, @Param("example") SysUsersExample example);

    int updateByPrimaryKeySelective(SysUsers row);

    int updateByPrimaryKey(SysUsers row);

    @Select("SELECT m.DESCN\n" +
            "FROM SYS_USERS u\n" +
            "INNER JOIN SYS_USER_ROLE ur ON u.ID = ur.USER_ID\n" +
            "INNER JOIN SYS_ROLES r ON r.ID = ur.ROLE_ID\n" +
            "INNER JOIN SYS_MENU_ROLE mr ON r.ID = mr.ROLE_ID\n" +
            "INNER JOIN SYS_MENUS m ON mr.MENU_ID = m.ID\n" +
            "WHERE u.LOGIN_ID = #{loginId}")
    List<String> findPermissionByName(String loginId);

    @Select("SELECT r.`NAME`\n" +
            "FROM SYS_USERS u\n" +
            "INNER JOIN SYS_USER_ROLE ur ON u.ID = ur.USER_ID\n" +
            "INNER JOIN SYS_ROLES r ON r.ID = ur.ROLE_ID\n" +
            "WHERE u.LOGIN_ID = #{loginId}")
    List<String> findRolesByName(String loginId);
}